package io.renren.modules.psfinancemanage.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.psfinancemanage.entity.PsFinanceManageEntity;
import io.renren.modules.psfinancemanage.service.PsFinanceManageService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;




/**
 * 财务管理
 * 
 * @author wangdajiang
 * @email 2750757088@qq.com
 * @date 2018-06-01 14:19:07
 */
@RestController
@RequestMapping("/psfinancemanage")
public class PsFinanceManageController {
	@Autowired
	private PsFinanceManageService psFinanceManageService;
	
	/**
	 * 财务汇总列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("psfinancemanage:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<PsFinanceManageEntity> psFinanceManageList = psFinanceManageService.queryList(query);
		int total = psFinanceManageService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(psFinanceManageList, total, query.getLimit(), query.getPage());
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("psfinancemanage:info")
	public R info(@PathVariable("id") Long id){
		PsFinanceManageEntity psFinanceManage = psFinanceManageService.queryObject(id);
		
		return R.ok().put("psFinanceManage", psFinanceManage);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("psfinancemanage:save")
	public R save(@RequestBody PsFinanceManageEntity psFinanceManage){
		psFinanceManageService.save(psFinanceManage);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("psfinancemanage:update")
	public R update(@RequestBody PsFinanceManageEntity psFinanceManage){
		psFinanceManageService.update(psFinanceManage);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("psfinancemanage:delete")
	public R delete(@RequestBody Long[] ids){
		psFinanceManageService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
